<template>
  <el-card style="margin-bottom: 20px">
    <template #header>
      <el-row :gutter="10" style="float: right">
        <el-button @click="toJSON" type="primary">JSON设置</el-button>
        <el-button @click="save">更 新</el-button>
      </el-row>
    </template>
  </el-card>
  <el-card header="报表基本信息">
    <el-form :model="form" label-position="left">
      <el-row>
        <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
          <el-form-item label="模块key" prop="模块key">
            <el-input v-model="form.appKey" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
          <el-form-item label="模块名称" prop="appName">
            <el-input v-model="form.appName"></el-input>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
          <el-form-item label="json文件名" prop="fileName">
            <el-input v-model="form.fileName"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </el-card>
</template>
  <script setup>
import { ref, defineModel, onMounted,inject } from "vue";
import API from "@/api/model/meta.js";
import { ElNotification } from "element-plus";
import { useRoute, useRouter } from "vue-router";
import ErCanvas from "@/components/tsER/index";
const emit = defineEmits(["update", "init"]);
const route = useRoute();
const router = useRouter();
const props = defineProps({
  configData: { type: Array, default: [] },
});
const form = defineModel();
const fileName = inject('fileName')
const toJSON = () => {
  console.log(fileName.value)
  router.push({
    path: "/JsonFileEditor",
    query: { fileName: fileName.value },
  });
};
const save = async () => {
  let param = {
    bean: form.value,
  };
  let res = API.updateBaseData.post(param);
  if (res.code == 200) {
    ElNotification.success({
      title: "",
      message: "操作成功！",
      duration: 2000,
    });
    emit("update");
    emit("init");
  }
};
</script>